package zqkcom.atguigu.utils;

import com.alibaba.druid.sql.ast.statement.SQLForeignKeyImpl;

import javax.servlet.http.HttpServletRequest;
import javax.xml.soap.SAAJResult;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class WebUtils {
    public static String getPath(HttpServletRequest request) {
        //获取当前请求的请求路径
        String requestURI = request.getRequestURI();
        //获取请求地址后所拼接的请求参数
        String queryString = request.getQueryString();
        if (queryString.contains("&pageNo")) {
            queryString = queryString.substring(0, queryString.indexOf("&pageNo"));
        }
        return requestURI+"?"+queryString;

    }

    public static void main(String[] args) {
        String reg_username ="^\\w{6,15}$";
        String username = "admin";
        username.matches(reg_username);//第一种方法
        Pattern.matches(reg_username, username);//第二种方法 ，第二原始

        Pattern pattern = Pattern.compile(reg_username);
        Matcher matcher = pattern.matcher(username);
        matcher.matches();//第三种方法 ，最原始的方法



    }

}
